<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="./css/font.css">
<link rel="stylesheet" href="./css/xadmin.css">
<script src="./lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="./js/xadmin.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
	<script>
		$(document).ready(function() {
			show();
		});

		function show() {
			$.ajax({
				url : "/admin/showcoachmanage",
				type : "post",
				dataType : "json",
				success : function(data) {
					var context = "";
					for (var i = 0; i < data.length; i++) {
						var po = data[i];
						context += '<tr id="trr' + i + '" ondblclick="de(' + i
								+ ')" onclick="getsender(' + po.chatid + ','
								+ po.sender + ')">'
								+ '<th width="10%"><font size="2">' + po.chatid
								+ '</font></th>'
								+ '<th width="10%"><font size="2">' + po.sender
								+ '</font></th>'
								+ '<th width="15%"><font size="2">' + po.deal
								+ '</font></th>'
								+ '<th width="20%"><font size="2">'
								+ po.mestime + '</font></th>'
								+ '<th width="55%"><font size="2">' + po.mes
								+ '</font></th>' + '</tr>'
					}
					$("#show_coachmes").html(context);
				}
			});
		}

		function agree(chatid, sender) {
			$.ajax({
				url : "/admin/agreecoach",
				type : "post",
				data : {
					chatid : chatid,
					sender : sender
				},
				success : function(data) {
					alert(data);
					window.location.reload();
				}
			});
		}

		function disagree(chatid, sender) {
			$.ajax({
				url : "/admin/disagreecoach",
				type : "post",
				data : {
					chatid : chatid,
					sender : sender
				},
				success : function(data) {
					alert(data);
					window.location.reload();
				}
			});
		}

		function getsender(chatid, sender) {
			var content = "";
			content = '<button class="layui-btn" onclick="agree(' + chatid
					+ ',' + sender + ')">同意</button>'
			$("#agreecoach").html(content);
			var disagree = "";
			disagree = '<button class="layui-btn" onclick="disagree(' + chatid
					+ ',' + sender + ')">拒绝</button>'
			$("#disagreecoach").html(disagree);
		}

		function de(u) {
			for (var i = 0; i < 50; i++) {
				if ($("#trr" + i).css('background-color') === 'rgb(84, 255, 159)')
					$("#trr" + i).css('background-color', 'white');
			}
			$("#trr" + u).css('background-color', '#54FF9F');
		}
	</script>
	<div class="layui-card-body">
		<table class="layui-table">
			<tr>
				<th width="10%">通知编号</th>
				<th width="10%">申请人ID</th>
				<th width="15%">处理状态</th>
				<th width="20%">时间</th>
				<th width="45%">内容</th>
			</tr>

			<tbody id="show_coachmes">

			</tbody>
		</table>
	</div>
	<label for="L_repass" class="layui-form-label" id="agreecoach">
		<button class="layui-btn">同意</button>
	</label>
	<label for="L_repass" class="layui-form-label" id="disagreecoach"><button
			class="layui-btn">拒绝</button></label>
	<label for="L_repass" class="layui-form-label"></label>
	<label for="L_repass" class="layui-form-label">
		<button onclick="xadmin.open('已读消息','./readycoach.html',900,500)"
			class="layui-btn">显示已处理消息</button>
	</label>
</body>
</html>
